﻿using System;
using System.Text;
using System.IO;

namespace FacadePattern.EncryptionModuleSample
{
    class FileReader
    {
        public string Read(string fileNameSrc) 
        {
		    Console.Write("读取文件，获取明文：");
           
            var sb = new StringBuilder();
		    try
            {
                using (FileStream fs = new FileStream(fileNameSrc, FileMode.Open))
                {
                    int data;
                    while ((data = fs.ReadByte()) != -1)
                    {
                        sb = sb.Append((char)data);
                    }
                }
     		    Console.WriteLine(sb.ToString());
		    }
		    catch(FileNotFoundException ex) 
            {
			    Console.WriteLine($"文件不存在！{ex.Message}");
		    }
		    catch(IOException ex) 
            {
			    Console.WriteLine($"文件操作错误！{ex.Message}");
		    }
		    return sb.ToString();
	    }
    }
}
